package com.springboot.jktj.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.springboot.common.annotation.Log;
import com.springboot.common.core.controller.BaseController;
import com.springboot.common.core.domain.AjaxResult;
import com.springboot.common.enums.BusinessType;
import com.springboot.jktj.domain.JktjDoctor;
import com.springboot.jktj.service.IJktjDoctorService;
import com.springboot.common.utils.poi.ExcelUtil;
import com.springboot.common.core.page.TableDataInfo;

/**
 * 医生列Controller
 * 
 * @author springboot
 * @date 2023-11-29
 */
@RestController
@RequestMapping("/jktj/doctor")
public class JktjDoctorController extends BaseController
{
    @Autowired
    private IJktjDoctorService jktjDoctorService;

    /**
     * 查询医生列列表
     */
    @PreAuthorize("@ss.hasPermi('jktj:doctor:list')")
    @GetMapping("/list")
    public TableDataInfo list(JktjDoctor jktjDoctor)
    {
        startPage();
        List<JktjDoctor> list = jktjDoctorService.selectJktjDoctorList(jktjDoctor);
        return getDataTable(list);
    }

    /**
     * 导出医生列列表
     */
    @PreAuthorize("@ss.hasPermi('jktj:doctor:export')")
    @Log(title = "医生列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JktjDoctor jktjDoctor)
    {
        List<JktjDoctor> list = jktjDoctorService.selectJktjDoctorList(jktjDoctor);
        ExcelUtil<JktjDoctor> util = new ExcelUtil<JktjDoctor>(JktjDoctor.class);
        util.exportExcel(response, list, "医生列数据");
    }

    /**
     * 获取医生列详细信息
     */
    @PreAuthorize("@ss.hasPermi('jktj:doctor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jktjDoctorService.selectJktjDoctorById(id));
    }

    /**
     * 新增医生列
     */
    @PreAuthorize("@ss.hasPermi('jktj:doctor:add')")
    @Log(title = "医生列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JktjDoctor jktjDoctor)
    {
        return toAjax(jktjDoctorService.insertJktjDoctor(jktjDoctor));
    }

    /**
     * 修改医生列
     */
    @PreAuthorize("@ss.hasPermi('jktj:doctor:edit')")
    @Log(title = "医生列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JktjDoctor jktjDoctor)
    {
        return toAjax(jktjDoctorService.updateJktjDoctor(jktjDoctor));
    }

    /**
     * 删除医生列
     */
    @PreAuthorize("@ss.hasPermi('jktj:doctor:remove')")
    @Log(title = "医生列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jktjDoctorService.deleteJktjDoctorByIds(ids));
    }
}
